package com.example.mymenu;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;

import java.util.logging.ConsoleHandler;

public class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.MenuHolder> {
    private Context context;
    private String[] menuStep;
    private String[] imagePic;

    public MenuAdapter(Context context, String[] menuStep,String[] imagePic){
        this.context = context;
        this.menuStep = menuStep;
        this.imagePic = imagePic;
    }


    @NonNull
    @Override
    public MenuHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v1 = View.inflate(context, R.layout.myiteamlayout,null);
        MenuHolder menuHolder = new MenuHolder(v1);
        return menuHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull MenuHolder holder, int position) {
        String stepTitle = Integer.toString(position + 1) + ". ";
        Log.d("success",stepTitle);
        String msg = stepTitle + menuStep[position];
        holder.textView.setText(msg);
        Glide.with(context).load(imagePic[position]).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return menuStep.length;
    }

    public class MenuHolder extends RecyclerView.ViewHolder {
        TextView textView;
        ImageView imageView;
        public MenuHolder(@NonNull View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.textView_Ncontent);
            imageView = itemView.findViewById(R.id.imageView_Ncotent);
        }
    }
}
